package dimension.starry.effect;

import dimension.starry.constants.ItemNbtTag;
import net.minecraft.entity.effect.StatusEffectInstance;
import net.minecraft.entity.effect.StatusEffects;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NbtCompound;

/**
 * @author 150149
 */
public class EffectResult {

    public static void onPlayerFinishUsingItem(PlayerEntity player, ItemStack itemStack) {
        if (itemStack.getNbt() != null) {
            NbtCompound nbtCompound = itemStack.getNbt();
            if (nbtCompound.contains(ItemNbtTag.FOOD_CREATED_TIME)) {
                long foodTime = nbtCompound.getLong(ItemNbtTag.FOOD_CREATED_TIME);
                if (player.getEntityWorld().getTime() - foodTime > 70000) {
                    player.addStatusEffect(new StatusEffectInstance(StatusEffects.POISON, 3000, 0));
                }
            }
        }
    }

}
